/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.ipti.br.tag.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author ipti
 */
public class LoginUtil {
    
    public static String selectNumbersLetters(String name) {
        String caracters = "abcdefghijklmnopqrstuvxzywABCDEFGHIJKLMNOPQRSTUVXZYW0123456789";
        String validateString = "";
        for(int i = 0; i < name.length(); i++) {
            String aux = name.substring(i, i+1);
            if(caracters.contains(aux)) {
                validateString += aux;
            }
        }
        return validateString;
    }
    
    public static String loginGenerator(String name) {
        try {
            String[] a = name.split(" ");
            int i = 1;
            name = a[0];
            while (i < a.length) {
                name += a[i];
                i++;
            }
            name = name.toLowerCase();
        } finally {
        }
        return name;
    }

    public static String passwordGenerator(String birthday) {
        String result = "";
        SimpleDateFormat in = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat out = new SimpleDateFormat("dd/MM/yyyy");
        try {
            result = out.format(in.parse(birthday.toString()));
        } catch (ParseException ex) {
            Logger.getLogger(LoginUtil.class.getName()).log(Level.SEVERE, null, ex);
        }
        result = result.replaceAll("/", "");
        return result;
    }
}
